using System;

namespace OccurrencesWeb.WebUserControl
{
    public partial class WucMessage : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (ValidationSummary.CssClass != "msgsuccess")
                    ValidationSummary.CssClass = "msgerror";
            }
            else
            {
                ValidationSummary.CssClass = "msgerror";
            }
        }

        public void ShowMessage(string message, bool isErrorMessage)
        {
            CustomValidator.IsValid = false;
            CustomValidator.ErrorMessage = message;

            if (isErrorMessage)
            {
                ValidationSummary.CssClass = "msgerror";
            }
            else
            {
                ValidationSummary.CssClass = "msgsuccess";
            }
        }

        public void SetValidationGroup(string validationGroup)
        {
            this.ValidationSummary.ValidationGroup = validationGroup;
            this.CustomValidator.ValidationGroup = validationGroup;
        }

        internal void ClearMessage()
        {
            CustomValidator.ErrorMessage = string.Empty;
        }
    }
}